import 'dart:isolate';

import 'package:simulator/core/module.dart';
import 'package:win32/win32.dart';

final class RegisiterUpdate {
  final int addr;
  final int oldValue;
  final int newValue;
  const RegisiterUpdate(this.addr, this.oldValue, this.newValue);
  @override
  String toString() =>
      '${addr.toHexString(8)}:[${oldValue.toHexString(8)}->${newValue.toHexString(8)}]';
}

final class Args {
  final SendPort port;
  final SendPort? ui;

  ///外围模块合集
  final List<Module>? module;
  const Args({this.module, required this.port, this.ui});
}

enum ResultType {
  ///未知指令
  unkonw,

  ///参数传递
  args,

  ///寄存器修改通知
  regisiter,

  ///异常事件
  exception,

  ///中断通知
  interrupt,

  ///退出
  exit
}

class Result {
  final ResultType type;
  final Args? args;
  final RegisiterUpdate? update;
  final Object? exception;
  const Result(
      {this.args, this.type = ResultType.unkonw, this.update, this.exception});

  @override
  String toString() {
    return '${type.name}:$update,$exception';
  }
}
